package me.numark.view;

import com.squareup.picasso.Picasso;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Date;

import butterknife.ButterKnife;
import butterknife.InjectView;
import me.numark.R;
import me.numark.utils.Utils;

/**
* Created by tian on 14/12/7:下午11:18.
*/
public class NewsViewHolder {

    @InjectView(R.id.news_icon)
    public ImageView icon;

    @InjectView(R.id.news_title)
    public TextView title;

    @InjectView(R.id.news_time)
    public TextView time;

    @InjectView(R.id.news_source)
    public TextView source;

    private Context mContext;

    public NewsViewHolder(View view, Context context) {
        ButterKnife.inject(this, view);
        mContext = context;
    }

    public void bindNewsView(String newsTitle, long timeStamp,
            String newsSource, String imageUrl, Date today, Date yesterday, Date year) {
        title.setText(newsTitle);
        time.setText(
                Utils.getTimeShowText(new Date(timeStamp), yesterday, today, year));
        source.setText(newsSource);
        if (!TextUtils.isEmpty(imageUrl)) {
            Picasso.with(mContext).load(imageUrl).into(icon);
        }
    }
}
